package com.study.spring_web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by 汪贵春 on 2017/2/26.
 */

@Controller
public class HelloController {

    @RequestMapping(value = "/{path}")
    public void spring(@PathVariable("path") String path, HttpServletResponse response) throws IOException {
        response.getWriter().write("hello spring web!,this is " + path);
    }

    @RequestMapping("/login")
//    @ResponseBody
    public String userPage(@RequestParam String userId, @RequestParam String password, Model model) {
//        return "userId=" + userId + "<p> msg=" + msg;
        model.addAttribute("name",userId);
        model.addAttribute("password",password);
        model.addAttribute("msg","hello!");
        return "user";
    }

}




